import request from '@/utils/request'

// 查询店铺授权列表
export function listShopAuth(query) {
  return request({
    url: '/amz/shopAuth/list',
    method: 'get',
    params: query
  })
}

// 查询店铺授权详细
export function getShopAuth(shopAuthId) {
  return request({
    url: '/amz/shopAuth/' + shopAuthId,
    method: 'get'
  })
}

// 新增店铺授权
export function addShopAuth(data) {
  return request({
    url: '/amz/shopAuth',
    method: 'post',
    data: data
  })
}

// 修改店铺授权
export function updateShopAuth(data) {
  return request({
    url: '/amz/shopAuth',
    method: 'put',
    data: data
  })
}

// 删除店铺授权
export function delShopAuth(shopAuthId) {
  return request({
    url: '/amz/shopAuth/' + shopAuthId,
    method: 'delete'
  })
}

// 导出店铺授权
export function exportShopAuth(query) {
  return request({
    url: '/amz/shopAuth/export',
    method: 'get',
    params: query
  })
}

//店铺授权/新增-通过当前登录人获取已维护的店铺
export function getShopCodeByUsername() {
  return request({
    url: '/amz/shopAuth/getShopCodeByUsername',
    method: 'post',
  })
}

//通过当前登录人获取自己授权的多个店铺信息
export function getShopCodeToShopAuth() {
  return request({
    url: '/amz/shopAuth/getShopCodeToShopAuth',
    method: 'post'
  })
}

//上传产品/选择店铺-通过店铺代码获取已授权的站点
export function getCountryCodeByShopCode(shopCode) {
  return request({
    url: '/amz/shopAuth/getCountryCodeByShopCode',
    method: 'post',
    data:shopCode
  })
}

// 通过区域代码获取spapi授权地址
export function getSpapiAuthUrl(sellingRegionCode) {
  return request({
    url: '/amz/shopAuth/getSpapiAuthUrl/'+sellingRegionCode,
    method: 'get'
  })
}

// 执行授权
export function executeAuth(formAuth) {
  return request({
    url: '/amz/shopAuth/executeAuth',
    method: 'post',
    params: {formAuth:JSON.stringify(formAuth)}
  })
}


// 删除店铺授权
export function syncOrder(shopAuthId) {
  return request({
    url: '/amz/shopAuth/syncOrder/' + shopAuthId,
    method: 'get'
  })
}
